//
// Created by BREEZE on 2023/2/18.
//

#include <jni.h>
#include <string>

const char *HE_KEY1 = "6fb32f3fb50e497e99327a90c3f38d81";
const char *HE_NAME1 = "HE2004142249371506";
const char *HE_KEY2 = "1a60596abb72406f9481c80fd4d97434";
const char *HE_NAME2 = "HE2006201749261763";

extern "C"
JNIEXPORT jobject JNICALL
Java_breeze_pixel_weather_service_app_1widget_WeatherUtils_getKeyData(JNIEnv *env, jclass clazz) {
    jclass pJclass_bundle = env->FindClass("android/os/Bundle");
    jmethodID pIdInitBundle = env->GetMethodID(pJclass_bundle, "<init>", "()V");
    jobject bundle = env->NewObject(pJclass_bundle, pIdInitBundle);
    jmethodID pIdPutString = env->GetMethodID(pJclass_bundle, "putString",
                                              "(Ljava/lang/String;Ljava/lang/String;)V");
    env->CallVoidMethod(bundle, pIdPutString, env->NewStringUTF("name_1"), env->NewStringUTF(HE_NAME1));
    env->CallVoidMethod(bundle, pIdPutString, env->NewStringUTF("key_1"), env->NewStringUTF(HE_KEY1));
    env->CallVoidMethod(bundle, pIdPutString, env->NewStringUTF("name_2"), env->NewStringUTF(HE_NAME2));
    env->CallVoidMethod(bundle, pIdPutString, env->NewStringUTF("key_2"), env->NewStringUTF(HE_KEY2));
    return bundle;
}

//TODO:更改请求域名
extern "C"
JNIEXPORT jstring JNICALL
Java_breeze_pixel_weather_apps_1util_utils_API_getApiHome(JNIEnv *env, jclass clazz) {
    return env->NewStringUTF("http://www.libreeze.top/pixelweather/");
}


const char *DONATE_NOTICE = "http://www.libreeze.top/pixelweather/Notice.php";
const char *DONATE_RETURN = "http://www.libreeze.top/pixelweather/return.php";
const char *DONATE_AMOUNT = "1";

extern "C"
JNIEXPORT jobject JNICALL
Java_breeze_pixel_weather_activity_DonateActivity_getDonateData(JNIEnv *env, jclass clazz) {
    jclass pJclass_bundle = env->FindClass("android/os/Bundle");
    jmethodID pIdInitBundle = env->GetMethodID(pJclass_bundle, "<init>", "()V");
    jobject bundle = env->NewObject(pJclass_bundle, pIdInitBundle);
    jmethodID pIdPutString = env->GetMethodID(pJclass_bundle, "putString",
                                              "(Ljava/lang/String;Ljava/lang/String;)V");
    env->CallVoidMethod(bundle, pIdPutString, env->NewStringUTF("notice"), env->NewStringUTF(DONATE_NOTICE));
    env->CallVoidMethod(bundle, pIdPutString, env->NewStringUTF("return"), env->NewStringUTF(DONATE_RETURN));
    env->CallVoidMethod(bundle, pIdPutString, env->NewStringUTF("amount"), env->NewStringUTF(DONATE_AMOUNT));
    return bundle;
}